#!/bin/bash

function usage
{
	echo "nothing matched, please enter one parameter:"
	echo "		<For  base>: base"
	echo "		------------------------"
	echo "		<For  all service>: all"
}

APP_HOME=/home/JHG/app/jebs-base
APP_JAR=jebs-base.jar
APP_PORT=8080

APP_LOG_DIR=$APP_HOME/logs

if [ $# -ne 1 ]
then
        usage
        exit 0
else
        param=$1
        echo $param
fi
if [ "$param" = "base" ]
then
        kill `ps -e -o pid,command|grep -v grep|grep $APP_JAR|awk '{print $1}'` >/dev/null
        rm -rf $APP_LOG_DIR/$APP_JAR.log
        nohup java -Dloader.path=$APP_HOME/lib -Dspring.profiles.active=prod -Dserver.port=$APP_PORT -jar -Xmx1024m -server $APP_HOME/$APP_JAR > $APP_LOG_DIR/$APP_JAR.log 2>&1 &
        echo "execute $param =======>>>"

elif [ "$param" = "all" ]
then
        "$0" base
else
        usage
fi
